home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-04 | 5.7 KB | 213 lines | [TEXT/CWIE] |
- //
- // C3DMFViewerApp.cp
- //
- // A PowerPlant application for viewing QuickDraw3D Metafiles
- //
- // by James Jennings
- // Started November 12, 1995
- //
-
- #include "C3DMFViewerApp.h"
- #include "C3DMFViewerDoc.h"
- #include "C3DMFViewerPane.h"
-
- #include "StQD3DInitializer.h"
-
- /*#include <StandardFile.h>
-
- #include <LApplication.h>
- #include <LGrowZone.h>
- #include <LWindow.h>
- #include <LScroller.h>
- #include <LPrintout.h>
- #include <LPlaceHolder.h>
-
- #include <UMemoryMgr.h>
- #include <UDrawingState.h>
- #include <URegistrar.h>
- #include <UDesktop.h>
-
- #include "CDocDemoApp.h"
- #include "CTextDoc.h"
- #include "CDirtyText.h"*/
-
- // ===========================================================================
- // • Main Program
- // ===========================================================================
-
- void main(void)
- {
- // Set Debugging options
- SetDebugThrow_(debugAction_Alert);
- SetDebugSignal_(debugAction_Alert);
-
- InitializeHeap(3); // Initialize Memory Manager
- // Parameter is number of Master Pointer
- // blocks to allocate
-
- // Initialize standard Toolbox managers
- UQDGlobals::InitializeToolbox(&qd);
-
- new LGrowZone(20000); // Install a GrowZone function to catch
- // low memory situations.
- // Parameter is size of reserve memory
- // block to allocated. The first time
- // the GrowZone function is called,
- // there will be at least this much
- // memory left (so you'll have enough
- // memory to alert the user or finish
- // what you are doing).
-
- StQD3DInitializer qd3dState; // initialize QuickDraw 3D
- if (qd3dState.GetStatus()==kQ3Success) {
- C3DMFViewerApp theApp; // Create instance of your Application
- theApp.Run(); // class and run it
- }
- }
-
-
- // ===========================================================================
- // • C3DMFViewerApp Class
- // ===========================================================================
-
- // ---------------------------------------------------------------------------
- // • C3DMFViewerApp
- // ---------------------------------------------------------------------------
- // Constructor
-
- C3DMFViewerApp::C3DMFViewerApp(void)
- {
- // Register classes for objects created from 'PPob' resources
- URegistrar::RegisterClass(LWindow::class_ID, LWindow::CreateWindowStream);
- // URegistrar::RegisterClass(LActiveScroller::class_ID,
- // LActiveScroller::CreateActiveScrollerStream);
- // URegistrar::RegisterClass(LPlaceHolder::class_ID, LPlaceHolder::CreatePlaceHolderStream);
- // URegistrar::RegisterClass(LPrintout::class_ID, LPrintout::CreatePrintoutStream);
- URegistrar::RegisterClass(LView::class_ID, LView::CreateViewStream);
-
- // dBug: Tell the Registar about our new QD3D Viewer Pane class
- URegistrar::RegisterClass(C3DMFViewerPane::class_ID,
- C3DMFViewerPane::CreateQ3ViewerPaneStream);
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~C3DMFViewerApp
- // ---------------------------------------------------------------------------
- // Destructor
-
- C3DMFViewerApp::~C3DMFViewerApp(void)
- {
- // +++ Add code here to cleanup (if necessary) before quitting
- }
-
- // ---------------------------------------------------------------------------
- // • StartUp
- // ---------------------------------------------------------------------------
- // Open a file the first thing.
-
- void C3DMFViewerApp::StartUp(void)
- {
- ObeyCommand(cmd_Open, nil);
- }
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- C3DMFViewerApp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
- // Remember to add same cases to FindCommandStatus below
- // to enable/disable the menu items for the commands
-
- default:
- cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // Pass back status of a (menu) command
-
- void
- C3DMFViewerApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- default:
- LDocApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
- outMark, outName);
- break;
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • OpenDocument
- // ---------------------------------------------------------------------------
- // Open a Document file
-
- void
- C3DMFViewerApp::OpenDocument(
- FSSpec *inMacFSSpec)
- {
- C3DMFViewerDoc *theDoc = new C3DMFViewerDoc(this, inMacFSSpec);
- }
-
-
- // ---------------------------------------------------------------------------
- // • MakeNewDocument
- // ---------------------------------------------------------------------------
- // Create a new Document
-
- /*LModelObject*
- C3DMFViewerApp::MakeNewDocument()
- {
- CTextDoc *theDoc = new CTextDoc(this, nil);
- return theDoc;
- }*/
-
-
- // ---------------------------------------------------------------------------
- // • ChooseDocument
- // ---------------------------------------------------------------------------
- // Prompt the user to select a document to open
-
- void
- C3DMFViewerApp::ChooseDocument()
- {
- StandardFileReply macFileReply;
- SFTypeList typeList;
-
- UDesktop::Deactivate();
- typeList[0] = '3DMF';
- ::StandardGetFile(nil, 1, typeList, &macFileReply);
- UDesktop::Activate();
- if (macFileReply.sfGood) {
- OpenDocument(&macFileReply.sfFile);
- }
- }
-